#include "gtest/gtest.h"

#include "../src/utils/array.h"
#include "../src/sort/sort.h"

using namespace csz;

TEST(ArrayTest, GetRandArr)
{
	int size1 = 10;
	int size2 = 20;
	int range = 100;
	Array<int> *a = Array<int>::GetRandArr(size1, range);
	Array<int> *b = Array<int>::GetRandArr(size1, size2, range);
	a->print();
	b->print();
	ASSERT_TRUE(a != NULL);
	ASSERT_TRUE(b != NULL);
	ASSERT_TRUE(a->getSize() == size1);
	ASSERT_TRUE(b->getSize() >= size1 && b->getSize() <= size2);
	delete a;
	delete b;
}

TEST(ArrayTest, Swap)
{
	int a = 1;
	int b = 2;
	Array<int>::Swap(&a, &b);
	ASSERT_EQ(a, 2);
	ASSERT_EQ(b, 1);
}

TEST(ArrayTest, Shuffle)
{
	SortFamily *sortFamily = new SortFamily();
	Array<int> *randArr = Array<int>::GetRandArr(20, 100);
	Array<int> *randArrCopy = randArr->copy();
	randArr->shuffle();
	randArrCopy->shuffle();
	sortFamily->BubbleSort(randArr->getArray(), randArr->getSize());
	sortFamily->BubbleSort(randArrCopy->getArray(), randArrCopy->getSize());
	ASSERT_TRUE(randArr->equal(randArrCopy));
}